package com.czl.module_storehouse.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.czl.module_storehouse.R;
import com.czl.module_storehouse.bean.InventoryBean;
import com.lihang.ShadowLayout;

import java.util.List;

/**
 * @author xubin
 */
public class InventoryListAdapter extends BaseQuickAdapter<InventoryBean, BaseViewHolder> {

    public InventoryListAdapter(int layoutResId, @Nullable List<InventoryBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, InventoryBean item) {
        helper.setText(R.id.tv_title, item.getInventoryName())
                .setText(R.id.tv_code, item.getInventoryCode("盘点单："))
                .setText(R.id.tv_department, item.getPropCompanyName("产权公司："))
                .setText(R.id.tv_num, "盘点数量：" + item.getStockNum())
                .setText(R.id.tv_date, item.getStatusStr())
                .setText(R.id.tv_inventory_date, "盘点时间：" + item.getInventoryDate());
        ShadowLayout shadowLayout = helper.getView(R.id.shadowLayout);
        shadowLayout.setShadowHiddenTop(0 != helper.getLayoutPosition());
        helper.getView(R.id.cl_root)
                .setOnClickListener(v -> {
                    if (getOnItemClickListener() != null) {
                        getOnItemClickListener().onItemClick(InventoryListAdapter.this, v, helper.getAbsoluteAdapterPosition());
                    }
                });
    }
}
